<?php

  $missions = $module->missions;

?>

<?php foreach($missions as $item): ?>
  <article class="panel" id="<?= slugify($item->name) ?>">

    <?php if(isset($item->image) && isset($item->image->logo)): ?>
    <figure class="right">
      <img src="<?= $item->image->logo ?>">
    </figure>
    <?php endif ?>

    <?php if(isset($item->eventdate)): ?>
    <hgroup>
      <h2><?= $item->name ?></h2>
      <p class="drophead"><?= NRHCdate($item->eventdate) ?></p>
    </hgroup>
    <?php else: ?>
    <h2><?= $item->name ?></h2>
    <?php endif ?>

    <?php if(isset($item->text)): ?>
    <p><?= $item->text ?></p>
    <?php endif ?>

    <?php if(isset($item->opportunities)): ?>
      <?php $oppLabel = isset($item->opportunities_label) ? $item->opportunities_label : "Opportunities"; ?>
    <h3><?= $oppLabel ?>:</h3>
    <ul>
      <?php foreach($item->opportunities as $opportunity): ?>
      <li>
        <strong><?= $opportunity->name ?></strong>:
        <?= $opportunity->text ?>
      </li>
      <?php endforeach ?>
    </ul>
    <?php endif ?>

    <?php if(isset($item->additional)): ?>
    <p><?= $item->additional ?></p>
    <?php endif ?>

    <?php if(isset($item->form_name)): ?>
    <p>
      <a href="<?= wufoo($item->form_name) ?>" class="button" target="_blank">Sign Up »</a>
    </p>
    <?php endif ?>

    <?php if(isset($item->location)): ?>
    <?php $location = new String($item->location); $location->replace(' ','+'); ?>
    <p class="footnote">The <?= $item->name ?> is located at <a href="https://maps.google.com/maps?q=<?= $location ?>"><?= $item->location ?></a></p>
    <?php endif ?>

    <?php if(isset($item->contact) && isset($item->contact->name)): ?>
    <p class="footnote">For more information 
      <?php if($item->contact->to_volunteer): ?>or to volunteer<?php endif ?>
      contact 
      <?= isset($item->contact->title) ? $item->contact->title : '' ?> <?= $item->contact->name ?>
      <?php if(isset($item->contact->email)): ?>
      by email <a href="mailto:<?= $item->contact->email ?>"><?= $item->contact->email ?></a>
      <?php endif ?>
      <?php if(isset($item->contact->phone)): ?>
      by phone <a href="tel:<?= $item->contact->phone ?>"><?= $item->contact->phone ?></a>
      <?php endif ?>
      <?php if(isset($item->contact->website)): ?>
      or visit <a href="<?= $item->contact->website ?>" target="_blank"><?= $item->contact->website ?></a>
      <?php endif ?>
    </p>
    <?php endif ?>

  </article>
<?php endforeach ?>
